package com.rtsffm.rtd.test;

import java.lang.reflect.Field;

//~--- classes ----------------------------------------------------------------

public class FieldAccessible {
    public static void main(String[] args) throws Exception {
        MyClass myClass = new MyClass();
        Field   field1  = myClass.getClass().getDeclaredField("theField");

        field1.setAccessible(true);
        System.out.println(field1.get(myClass));

        Field field2 = myClass.getClass().getDeclaredField("theField");

        System.out.println(field2.get(myClass));
    }

    //~--- inner classes ------------------------------------------------------

    public static class MyClass {
        private String theField;

        //~--- get methods ----------------------------------------------------

        public String getTheField() {
            return theField;
        }

        //~--- set methods ----------------------------------------------------

        public void setTheField(String theField) {
            this.theField = theField;
        }
    }
}
